package yxy.game.pm2.active.module.sdk.weixin;

import yxy.apple.util.PubSub.MethodSubscriber;
import yxy.apple.util.PubSub.SubscriptionMethod;
import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.bean.pubsub.PlayerBeanPublisher;
import yxy.game.pm2.bean.pubsub.PlayerBeanPublisher.PlayerBeanSubscription;
import yxy.game.pm2.bean.sdk.WeiXinOtherParm;

/**
 * 活动订阅
 * @author Dell
 *
 */
public class ActiveSubscriber_邀请好友 extends MethodSubscriber {

	static private ActiveSubscriber_邀请好友 instance;

	public static ActiveSubscriber_邀请好友 getInstance() {
		if (instance == null) {
			instance = new ActiveSubscriber_邀请好友();
			instance.init();
		}
		return instance;
	}

	private void init() {
		PlayerBeanPublisher.getInstance().subscribe(this);
	}
	
	private ActiveSubscriber_邀请好友() {
	}

	@SubscriptionMethod(Type = PlayerBeanSubscription.class)
	public void receive(PlayerBeanSubscription subscription) {
		PlayerBean playerBean = subscription.getPlayerBean();
		String playerCode = playerBean.getCode();
		
		if(WeiXinOtherParm.get(playerBean.getUid()) == null) {
			return;
		}
		
		ActiveModule_邀请好友 am = ActiveModule_邀请好友.get(playerCode);
		if(am.getInvitecode() == null) {
			return;
		}
		
		if(am.getInvitecode().equals(ActiveModule_邀请好友.mrinvitecode)) {
			return;
		}
		
		ActiveModule_邀请好友 inviteam = ActiveModule_邀请好友.get(am.getInvitecode());
		inviteam.dealbeinvited(playerBean);
	}
}
